package com.demo.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class ProcessJar {
    public static void main(String[] args) throws IOException {
        String[] cmdarray = {"java","-jar","/data/app/scheduler-worker/sql-action/scheduler-sql-action-1.0.jar","9","1"};
        Process p = Runtime.getRuntime().exec(cmdarray);
        BufferedReader ir = new BufferedReader(new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8));
        BufferedReader er = new BufferedReader(new InputStreamReader(p.getErrorStream(),StandardCharsets.UTF_8));

        String s = null;
        while ((s = ir.readLine()) != null)
        {
            System.out.println(s);
        }

        while ((s = er.readLine()) != null)
        {
            System.out.println(s);
        }
    }
}
